﻿#ifndef DATASOURCEOBJECT_H
#define DATASOURCEOBJECT_H

#include <QString>
#include <QJsonObject>

//user_mail user_name user_pwd
class DataSourceObject
{
public:
    DataSourceObject(const QJsonObject &obj){
        m_data = obj;
    }

    DataSourceObject(const QString &obj){
        m_data["user_mail"] = obj;
    }

    QString mail() const{
        return m_data.value("user_mail").toString();
    }

    QString name() const{
        return m_data.value("user_name").toString();
    }

    QString img() const{
        return m_data.value("user_img").toString();
    }

    QString getValue(const QString &key){
        return m_data.value(key).toString();
    }

    void setValue(QJsonObject &obj){
        m_data = obj;
    }

    void setValue(const QString &key,QJsonValue value){
        m_data.insert(key,value);
    }

    inline bool operator==(const QString &other) const{
        return this->mail() == other;
    }

    inline bool operator==(const DataSourceObject &other) const{
        return this->mail() == other.mail();
    }

private:
    QJsonObject m_data;
};

#endif // DATASOURCEOBJECT_H
